<?php
header("Content-type:text/html;charset=utf-8");
require 'collect.fun.php';

$id = isset($_GET['id']) ? $_GET['id'] : 42931;
$url = "http://data.movie.xunlei.com/movie/$id";
$code = file_get_contents($url);

//get movie intro
$movie_intro = strget($code, '<p>', '<a target="_blank"','<h3>剧情简介</h3>');

//cut code
$code = strget($code, '<div class="moviePic">', '<div class="movieScore');

//get name and logo
$temp = matchall('/<img id="img_movie_120x168" src="(.*)" alt="(.*)" \/>/i', $code);
$movie_logo = $temp[0][1];
$movie_name = $temp[0][2];

//get directors
$movie_directors = '';
$temp = matchall('/href="person\/(.*?)"(.*)>(.*)<\/a>/i', strget($code,'<p><strong>导演: </strong>','<p><strong>主演: </strong>'));
foreach ($temp as $v) {
	$movie_directors .= ' || '.$v[1].'_'.$v[3];
}

//get performers
$movie_performers = '';
$temp = matchall('/href="person\/(.*?)"(.*?)>(.*?)<\/a>/i', strget($code,'<p><strong>主演: </strong>','<p><strong>制片国家/地区: </strong>'));
foreach ($temp as $v) {
	$movie_performers .= ' || '.$v[1].'_'.$v[3];
}

//get area
$movie_area = '';
$temp = matchall('/href="type,area\/movie,(\d*)">(.*?)<\/a>/i', $code);
foreach ($temp as $v) {
	$movie_area .= ' || '.$v[1].'_'.$v[2];
}

//get genre
$movie_genre = '';
$temp = matchall('/href=\'type,genre\/movie,(.*?)\'>(.*?)<\/a>/i', $code);
foreach ($temp as $v) {
	$movie_genre .= ' || '.$v[1].'_'.$v[2];
}

li($movie_name, $movie_logo, $movie_directors, $movie_performers, $movie_area,$movie_genre, $movie_intro);
?>